package org.qqcui.designpattern.patterns.decorator.decorator;

import org.qqcui.designpattern.patterns.decorator.component.Drink;

/**
 * 装饰器类
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/4/29 10:51
 **/
public class Decorator extends Drink {

    private Drink drink;

    public Decorator(Drink drink) {
        this.drink = drink;
    }

    @Override
    public float cost() {
        // 自己的价格，加上咖啡的价格
        return super.getPrice() + drink.cost();
    }

    @Override
    public String getDesc() {
        return super.getDesc() + " " + drink.getDesc();
    }
}
